Skip to content

feat(webhookcerts): add --enable-webhook-cert-reconciler flag - #8541

Closed
patjlm wants to merge 1 commit into
openshift:mainfrom
patjlm:GCP-709-disable-webhook-cert-reconciliation
Closed

feat(webhookcerts): add --enable-webhook-cert-reconciler flag#8541
patjlm wants to merge 1 commit into
openshift:mainfrom
patjlm:GCP-709-disable-webhook-cert-reconciliation

Conversation

@patjlm

@patjlm patjlm commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add --enable-webhook-cert-reconciler flag (default true) to hypershift-operator run, hypershift install, and hypershift install render
  • When set to false, the WebhookCertReconciler switches to caBundle-only mode: reads the CA from the serving cert secret's ca.crt key instead of self-managing certificates
  • CRD and webhook configuration caBundle patching continues to work in both modes

Context

The WebhookCertReconciler (introduced in #8174) self-manages the webhook-serving-ca and manager-serving-cert secrets. In deployments using cert-manager to manage the webhook serving certificate (e.g. to solve the chicken-and-egg problem where the operator needs the secret mounted before it can start), the two controllers fight over the same secret, causing an infinite reconciliation loop (~120+ reissuances in minutes).

This flag allows disabling the cert generation while preserving the caBundle patching that CRDs and webhook configurations need.

Ref: GCP-709

Changes

File Change
hypershift-operator/controllers/webhookcerts/webhookcerts_controller.go Split Reconcile into reconcileCerts (full mode) and readCABundleFromServingCert (caBundle-only mode) gated by ManageCerts field
hypershift-operator/main.go Add EnableWebhookCertReconciler to StartOptions, register --enable-webhook-cert-reconciler flag, wire to ManageCerts
cmd/install/install.go Add flag to install Options, register as PersistentFlag, wire to deployment struct
cmd/install/assets/hypershift_operator.go Add field to HyperShiftOperatorDeployment, emit --enable-webhook-cert-reconciler=false in rendered args
*_test.go 4 new caBundle-only mode tests + updated install assets tests

Test plan

  • All existing TestReconcile tests pass (no regression with ManageCerts: true)
  • New TestReconcileCABundleOnly tests: CA patching from serving cert, missing secret error, missing ca.crt error, no CA secret creation
  • TestAddWebhookResources updated: flag rendered in args when disabled, not rendered when enabled
  • Manual test with cert-manager managing manager-serving-cert — verify no reconciliation loop

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added --enable-webhook-cert-reconciler installation flag to control webhook certificate management behavior (default: enabled).
    • Webhook certificate reconciler now supports dual modes: certificate management mode for operator-managed TLS certificates, or CA-bundle-only mode for external certificate manager integration.

Add a new --enable-webhook-cert-reconciler flag (default true) to the
hypershift operator, hypershift install, and hypershift install render
commands. When set to false, the WebhookCertReconciler skips self-managed
certificate generation and instead reads the CA bundle from the serving
cert secret's ca.crt key (as populated by an external certificate manager
such as cert-manager). The reconciler continues to patch CRDs and webhook
configurations with the CA bundle in both modes.

This allows deployments using cert-manager to manage webhook TLS
certificates without triggering an infinite reconciliation loop between
cert-manager and the built-in WebhookCertReconciler.

Ref: GCP-709

Signed-off-by: Patrick Martin <patmarti@redhat.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 19, 2026
@openshift-ci

openshift-ci Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci

openshift-ci Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: patjlm
Once this PR has been reviewed and has the lgtm label, please assign sjenning for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added area/cli Indicates the PR includes changes for CLI area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release and removed do-not-merge/needs-area labels May 19, 2026
@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 0bea854c-432f-4625-90fc-f4194ecfb618

📥 Commits

Reviewing files that changed from the base of the PR and between cf2b91f and 0ff3e4e.

📒 Files selected for processing (6)
  • cmd/install/assets/hypershift_operator.go
  • cmd/install/assets/hypershift_operator_test.go
  • cmd/install/install.go
  • hypershift-operator/controllers/webhookcerts/webhookcerts_controller.go
  • hypershift-operator/controllers/webhookcerts/webhookcerts_controller_test.go
  • hypershift-operator/main.go

📝 Walkthrough

Walkthrough

This PR introduces a new --enable-webhook-cert-reconciler flag at both the install and operator levels, allowing operators to disable managed webhook TLS certificate reconciliation. The install command wires this option through to the operator deployment args. The operator startup reads the flag and configures the webhook cert controller's ManageCerts mode. The controller now supports two modes: when ManageCerts is true (default), it actively reconciles and manages webhook certificates; when false, it runs in CA-bundle-only mode, reading the CA bundle from an externally-provided serving secret and patching webhook configurations without creating certificates. Tests validate the new CA-bundle-only behavior.

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and concisely describes the primary change: adding a new --enable-webhook-cert-reconciler flag to control webhook certificate reconciliation behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed All test names in modified test files are stable and deterministic. Tests use static string literals without dynamic content like pod names, timestamps, UUIDs, or variable interpolation.
Test Structure And Quality ✅ Passed Tests meet all requirements: single responsibility per test, proper unit test setup, no timeout issues, assertion patterns match codebase conventions.
Microshift Test Compatibility ✅ Passed No Ginkgo e2e tests were added in this PR. The test changes are unit tests using testing.T and Gomega, not Ginkgo e2e tests. The MicroShift compatibility check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR does not add Ginkgo e2e tests. Modified test files use standard Go unit testing (testing.T and t.Run), not Ginkgo. SNO compatibility check applies only to Ginkgo e2e tests.
Topology-Aware Scheduling Compatibility ✅ Passed No scheduling constraints introduced. Only a feature flag for webhook cert reconciliation was added. No affinity, topology spread, or node targeting rules.
Ote Binary Stdout Contract ✅ Passed No new stdout writes in process-level code. Changes are struct fields, flag registrations, and controller logic. Logger uses zap (stderr). Compliant with OTE Binary Stdout Contract.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR adds no Ginkgo e2e tests. Changes are limited to standard Go unit tests and source code. Custom check applies only to Ginkgo e2e tests, so not applicable here.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.69231% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.11%. Comparing base (7111d4d) to head (0ff3e4e).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...ontrollers/webhookcerts/webhookcerts_controller.go 54.54% 17 Missing and 3 partials ⚠️
hypershift-operator/main.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8541      +/-   ##
==========================================
+ Coverage   40.10%   40.11%   +0.01%     
==========================================
  Files         753      753              
  Lines       92985    93018      +33     
==========================================
+ Hits        37288    37313      +25     
- Misses      53001    53009       +8     
  Partials     2696     2696              
Files with missing lines Coverage Δ
cmd/install/assets/hypershift_operator.go 48.18% <100.00%> (+0.08%) ⬆️
cmd/install/install.go 61.86% <100.00%> (+0.09%) ⬆️
hypershift-operator/main.go 0.00% <0.00%> (ø)
...ontrollers/webhookcerts/webhookcerts_controller.go 64.40% <54.54%> (+1.28%) ⬆️
Flag Coverage Δ
cmd-support 34.30% <100.00%> (+0.01%) ⬆️
cpo-hostedcontrolplane 40.57% <ø> (ø)
cpo-other 40.14% <ø> (ø)
hypershift-operator 50.63% <52.17%> (+0.02%) ⬆️
other 31.54% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli Indicates the PR includes changes for CLI area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant